package com.xzy.seckill.common.annotations;

import com.xzy.seckill.common.validator.IsMobileValidator;

import javax.validation.Constraint;
import javax.validation.Payload;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.ElementType.TYPE_USE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = {IsMobileValidator.class})  //校验规则类（打上此注解的字段如何进行校验）
public @interface IsMobile {

    boolean required() default true; //手机号是否必填

    String message() default "手机号格式错误";  //错误信息

    Class<?>[] groups() default { };

    Class<? extends Payload>[] payload() default { };
}
